<section class="ev-sm-container ev-view challenge-container">
    <div class="ev-md-container ev-card-panel ev-z-depth-5 ev-challenge-view">
        <div class="row margin-bottom-cancel">
            <div class="col s12">
                <h5 class="w-300">My Submissions</h5>
                <h6>My Participated Team: {{challenge.participated_team_name}}</h6>
            </div>
        </div>
        <div class="row">
            <div ng-click="challenge.refreshSubmissionData()" class="pointer update-page" ng-if="challenge.showUpdate">
                <span class="text-white">Page is Outdated, Click to update&nbsp; <i
                        class="fa fa-refresh text-highlight"></i></span>
            </div>
            <div class="row fs-16 w-300">
                <div class="col s12 m6 l6">
                    <md-select ng-model="challenge.phase.name" placeholder="Select phase" class="rm-margin">
                        <md-option ng-click="challenge.getResults(key.id)" value="{{key.name}}"
                            ng-repeat="key in challenge.phases.results">{{key.name}} <span
                                class="new badge orange-background" data-badge-caption="Private"
                                ng-if="key.showPrivate"></span></md-option>
                    </md-select>
                </div>
            </div>
            <div class="row">
                <div class="col s12 m6 l6">
                    <md-select ng-model="challenge.fileSelected" placeholder="File type" class="rm-margin">
                        <md-option ng-repeat="key in challenge.fileTypes" value={{key.name}}>{{key.name}}
                        </md-option>
                    </md-select>
                    </p>
                    <a class="waves-effect waves-dark btn ev-btn-dark w-300 fs-16"
                        ng-click="challenge.downloadChallengeSubmissions()">Download</a>
                </div>
            </div>
            <div class="col s12 m4" ng-if="challenge.phaseId && challenge.isResult">
                <div class="add-line-height">
                    <span>
                        <strong class="text-med-black fs-16 w-300">
                            Total Submissions:
                        </strong>
                    </span>
                    <span class="show-count text-highlight">
                        {{challenge.submissionCount|| 0}}
                    </span>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col s12">
                <div ng-if="!challenge.showPagination && challenge.isResult" class="result-wrn fs-16 w-300">No
                    results found.</div>
                <div class="all-submission-table-scroll" ng-if="challenge.showPagination && challenge.isResult">
                    <table class="highlight all-submission-table" class="fs-16 w-300">
                        <thead>
                            <th class="fs-18 w-300" data-field="submission_id">#</th>
                            <th class="fs-18 w-300" data-field="method-name" ng-if="challenge.currentPhaseMetaAttributesVisibility['method_name'] != false">Method</th>
                            <th class="fs-18 w-300" data-field="method-description" ng-if="challenge.currentPhaseMetaAttributesVisibility['method_description'] != false">Method description</th>
                            <th class="fs-18 w-300" data-field="project-url" ng-if="challenge.currentPhaseMetaAttributesVisibility['project_url'] != false">Project URL</th>
                            <th class="fs-18 w-300" data-field="publication-url" ng-if="challenge.currentPhaseMetaAttributesVisibility['publication_url'] != false">Publication URL </th>
                            <th class="fs-18 w-300" data-field="status">Status</th>
                            <th class="fs-18 w-300" data-field="status">Execution time (sec.)</th>
                            <th class="fs-18 w-300" data-field="file">Submitted file</th>
                            <th class="fs-18 w-300" data-field="file">Result file</th>
                            <th class="fs-18 w-300" data-field="file">Stdout file</th>
                            <th class="fs-18 w-300" data-field="file">Stderr file</th>
                            <th class="fs-18 w-300" ng-if="challenge.isChallengeHost &&
                                    !challenge.isStaticCodeUploadChallenge" data-field="file">Environment Logs</th>
                            <th class="align-center fs-18 w-300" data-field="file">Submitted at</th>
                            <th class="align-center fs-18 w-300" ng-if="challenge.currentPhaseLeaderboardPublic"
                                data-field="file">
                                Show on leaderboard</th>
                            <th class="fs-18 w-300" data-field="isBaseline" ng-if="challenge.isChallengeHost">Baseline
                            </th>
                            <th class="fs-18 w-300">Edit</th>
                            <th class="fs-18 w-300">Cancel</th>
                            <th class="fs-18 w-300" ng-if="challenge.allowParticipantsResubmissions" data-field="button">Rerun submission</th>
                            <th class="fs-18 w-300" ng-if="challenge.allowParticipantsResubmissions && challenge.allowResumingSubmissions" data-field="button">Resume submission</th>
                        </thead>
                        <tbody>
                            <tr ng-repeat="key in challenge.submissionResult.results" class="result-val fs-16 w-300">
                                <td>{{$index + 1 + (challenge.currentRefPage - 1) * 150}}</td>
                                <td ng-if="key.method_name != '' && challenge.currentPhaseMetaAttributesVisibility['method_name'] != false">{{key.method_name}}</td>
                                <td ng-if="key.method_name == '' && challenge.currentPhaseMetaAttributesVisibility['method_name'] != false"> None </td>

                                <td ng-if="key.method_description != '' && challenge.currentPhaseMetaAttributesVisibility['method_description'] != false">{{key.method_description}}</td>
                                <td ng-if="key.method_description == '' && challenge.currentPhaseMetaAttributesVisibility['method_description'] != false"> None </td>

                                <td ng-if="key.project_url != '' && challenge.currentPhaseMetaAttributesVisibility['project_url'] != false">{{key.project_url}}</td>
                                <td ng-if="key.project_url == '' && challenge.currentPhaseMetaAttributesVisibility['project_url'] != false"> None </td>

                                <td ng-if="key.publication_url != '' && challenge.currentPhaseMetaAttributesVisibility['publication_url'] != false">{{key.publication_url}}</td>
                                <td ng-if="key.publication_url == '' && challenge.currentPhaseMetaAttributesVisibility['publication_url'] != false"> None </td>

                                <td class="val-style capitalize" ng-class="key.status">{{key.status}}</td>
                                <td class="align-center">
                                    {{key.execution_time > 0 ? key.execution_time : "None"}}</td>

                                <td><a href="{{key.input_file}}" target="_blank" class="blue-text"><i
                                            class="fa fa-external-link"></i> Link</a></td>

                                <td ng-if="key.submission_result_file"><a href="{{key.submission_result_file}}"
                                        target="_blank" class="blue-text"><i class="fa fa-external-link"></i>
                                        Link</a>
                                </td>
                                <td ng-if="!key.submission_result_file">None</td>

                                <td ng-if="key.stdout_file"><a href="{{key.stdout_file}}" target="_blank"
                                        class="blue-text"><i class="fa fa-external-link"></i> Link</a></td>
                                <td ng-if="!key.stdout_file">None</td>

                                <td ng-if="key.stderr_file"><a href="{{key.stderr_file}}" target="_blank"
                                        class="blue-text"><i class="fa fa-external-link"></i> Link</a></td>
                                <td ng-if="!key.stderr_file">None</td>

                                <td ng-if="key.environment_log_file && challenge.isChallengeHost &&
                                        !challenge.isStaticCodeUploadChallenge">
                                    <a href="{{key.environment_log_file}}" target="_blank"
                                        class="blue-text"><i class="fa fa-external-link"></i> Link</a></td>
                                <td ng-if="!key.environment_log_file && challenge.isChallengeHost &&
                                        !challenge.isStaticCodeUploadChallenge">None</td>

                                <td>{{key.submitted_at | date:'medium'}}</td>

                                <td ng-if="challenge.currentPhaseLeaderboardPublic" class="center">
                                    <input ng-checked="key.is_public" ng-if="!challenge.isCurrentPhaseRestrictedToSelectOneSubmission"
                                        ng-model="challenge.submissionVisibility[key.id]" type="checkbox"
                                        id="isPublic{{ key.id }}"
                                        ng-change="challenge.changeSubmissionVisibility(key.id, challenge.submissionVisibility[key.id])" />
                                    <input ng-checked="key.is_public" ng-if="challenge.isCurrentPhaseRestrictedToSelectOneSubmission"
                                        ng-model="challenge.submissionVisibility[key.id]" type="checkbox"
                                        id="isPublicSubmission{{ key.id }}"
                                        ng-change="challenge.showVisibilityDialog(key.id, challenge.submissionVisibility[key.id])" />
                                    <label ng-if="!challenge.isCurrentPhaseRestrictedToSelectOneSubmission"
                                           for="isPublic{{ key.id }}"></label>
                                    <label ng-if="challenge.isCurrentPhaseRestrictedToSelectOneSubmission"
                                           for="isPublicSubmission{{ key.id }}"></label>
                                </td>
                                <td ng-if="challenge.isChallengeHost" class="center">
                                    <input ng-checked="key.is_baseline" ng-if="key.status == 'finished' || key.status == 'partially_evaluated'"
                                        ng-model="challenge.baselineStatus[key.id]" type="checkbox"
                                        id="baselineSubmission{{ key.id }}"
                                        ng-change="challenge.changeBaselineStatus(key.id)" />
                                    <label for="baselineSubmission{{ key.id }}"></label>
                                    <span ng-if="key.status !== 'finished' && key.status !== 'partially_evaluated'" class="center"> N/A </span>
                                </td>
                                <td><a class="pointer" ng-click="challenge.showMdDialog($event, key.id)"><i
                                            class="fa fa-pencil" aria-hidden="true"></i></a></td>
                                <td><a class="times" ng-click="challenge.showCancelSubmissionDialog(key.id, key.status)"><i
                                    class="fa fa-times" aria-hidden="true"></i></a></td>
                                <td>
                                    <center><a ng-if="challenge.allowParticipantsResubmissions" ng-class="key.classList" class="fa fa-refresh pointer" ng-click="challenge.reRunSubmission(key)"></a>
                                    </center>
                                </td>
                                <td ng-if="challenge.allowParticipantsResubmissions && challenge.allowResumingSubmissions">
                                    <center><a ng-class="key.classList2" class="fa fa-play pointer" ng-click="challenge.resumeSubmission(key)"></a>
                                    </center>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <section class="pagination" ng-if="challenge.showPagination && challenge.isResult">
        <div class="row">
            <div class="col s12 left-align">
                <a ng-class="challenge.isPrev" class="btn-floating btn-pagination waves-effect waves-light "
                    ng-click="challenge.load(challenge.submissionResult.previous)">
                    <i class="fa fa-chevron-left"></i>
                </a>
                <span class="pagination-title"> <strong class="text-med-black"> Page
                        {{challenge.currentPage | ceil}} of {{challenge.submissionResult.count/100 | ceil}}
                    </strong></span>
                <a ng-class="challenge.isNext" class="btn-floating btn-pagination waves-effect waves-light "
                    ng-click="challenge.load(challenge.submissionResult.next)">
                    <i class="fa fa-chevron-right"></i>
                </a>
            </div>
        </div>
    </section>
</section>

<div class="loader-container card-loader-container" id="loader" ng-show="challenge.isExistLoader" class="fade">
    <div class="loader">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
</div>
